package fr.labri.macchiato.core.service;

import java.util.HashSet;
import java.util.Set;

import fr.labri.macchiato.core.api.Finder;

/**
 * 
 * Singleton class regrouping all services and their associated repositories
 * 
 * @author Matthieu Foucault
 * 
 */
public class Services {

	private static Services instance;

	/**
	 * @return the singleton's instance
	 */
	public static Services getInstance() {
		if (instance == null) {
			instance = new Services();
		}
		return instance;
	}

	private PreferencesService preferencesService;
	private ProjectService projectService;

	private Set<Finder> productFinders;
	private BusinessEntityService businessEntityService;

	/**
	 * Default Constructor <br>
	 * Initializes the repositories
	 */
	private Services() {
		productFinders = new HashSet<Finder>();
	}

	public void setProductFinders(Set<Finder> productFinders) {
		this.productFinders = productFinders;
	}

	/**
	 * @return The {@link PreferencesService}
	 */
	public PreferencesService getPreferencesService() {
		return preferencesService;
	}

	public void setPreferencesService(PreferencesService preferencesService) {
		this.preferencesService = preferencesService;
	}

	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}

	public void setBusinessEntityService(BusinessEntityService businessEntityService) {
		this.businessEntityService = businessEntityService;
	}
	
	/**
	 * @return the {@link ProjectService}
	 */
	public ProjectService getProjectService() {
		return projectService;
	}

	/**
	 * @return the {@link Finder}
	 */
	public Set<Finder> getProductFinders() {
		return productFinders;
	}

	public void addProductFinder(Finder productFinder) {
		this.productFinders.add(productFinder);
	}

	/**
	 * 
	 * @return the {@link BusinessEntityService}
	 */
	public BusinessEntityService getBusinessEntityService() {
		
		return businessEntityService;
	}

}
